// ----------> GENERATED FILE - DON'T TOUCH! <----------

// generator: ilarkesto.mda.legacy.generator.EntityGenerator










package scrum.server.project;

import java.util.*;
import ilarkesto.core.logging.Log;
import ilarkesto.persistence.ADatob;
import ilarkesto.persistence.AEntity;
import ilarkesto.persistence.AStructure;
import ilarkesto.auth.AUser;
import ilarkesto.persistence.EntityDoesNotExistException;
import ilarkesto.base.Str;

public abstract class GScenario
            extends AEntity
            implements ilarkesto.auth.ViewProtected<scrum.server.admin.User>, ilarkesto.search.Searchable, java.lang.Comparable<Scenario> {

    // --- AEntity ---

    public final scrum.server.project.ScenarioDao getDao() {
        return scenarioDao;
    }

    protected void repairDeadDatob(ADatob datob) {
    }

    @Override
    public void storeProperties(Map properties) {
        super.storeProperties(properties);
        properties.put("projectId", this.projectId);
        properties.put("number", this.number);
        properties.put("points", this.points);
        properties.put("remaining", this.remaining);
        properties.put("state", this.state);
        properties.put("priority", this.priority);
        properties.put("criticism", this.criticism);
        properties.put("criticismValue", this.criticismValue);
        properties.put("priorityValue", this.priorityValue);
        properties.put("label", this.label);
        properties.put("stimulus", this.stimulus);
        properties.put("sourceOfStimulus", this.sourceOfStimulus);
        properties.put("artifactStimulated", this.artifactStimulated);
        properties.put("environment", this.environment);
        properties.put("response", this.response);
        properties.put("responseMeasure", this.responseMeasure);
        properties.put("qualitysIds", this.qualitysIds);
        properties.put("storiesAssociatesIds", this.storiesAssociatesIds);
    }

    public int compareTo(Scenario other) {
        return toString().toLowerCase().compareTo(other.toString().toLowerCase());
    }

    public final java.util.Set<scrum.server.project.Requirement> getRequirements() {
        return requirementDao.getRequirementsByRelatedScenario((Scenario)this);
    }

    private static final ilarkesto.core.logging.Log LOG = ilarkesto.core.logging.Log.get(GScenario.class);

    public static final String TYPE = "scenario";


    // -----------------------------------------------------------
    // - Searchable
    // -----------------------------------------------------------

    public boolean matchesKey(String key) {
        if (super.matchesKey(key)) return true;
        if (matchesKey(getLabel(), key)) return true;
        if (matchesKey(getStimulus(), key)) return true;
        if (matchesKey(getSourceOfStimulus(), key)) return true;
        if (matchesKey(getArtifactStimulated(), key)) return true;
        if (matchesKey(getEnvironment(), key)) return true;
        if (matchesKey(getResponse(), key)) return true;
        if (matchesKey(getResponseMeasure(), key)) return true;
        return false;
    }

    // -----------------------------------------------------------
    // - project
    // -----------------------------------------------------------

    private String projectId;
    private transient scrum.server.project.Project projectCache;

    private void updateProjectCache() {
        projectCache = this.projectId == null ? null : (scrum.server.project.Project)projectDao.getById(this.projectId);
    }

    public final String getProjectId() {
        return this.projectId;
    }

    public final scrum.server.project.Project getProject() {
        if (projectCache == null) updateProjectCache();
        return projectCache;
    }

    public final void setProject(scrum.server.project.Project project) {
        project = prepareProject(project);
        if (isProject(project)) return;
        this.projectId = project == null ? null : project.getId();
        projectCache = project;
        updateLastModified();
        fireModified("project="+project);
    }

    protected scrum.server.project.Project prepareProject(scrum.server.project.Project project) {
        return project;
    }

    protected void repairDeadProjectReference(String entityId) {
        if (this.projectId == null || entityId.equals(this.projectId)) {
            repairMissingMaster();
        }
    }

    public final boolean isProjectSet() {
        return this.projectId != null;
    }

    public final boolean isProject(scrum.server.project.Project project) {
        if (this.projectId == null && project == null) return true;
        return project != null && project.getId().equals(this.projectId);
    }

    protected final void updateProject(Object value) {
        setProject(value == null ? null : (scrum.server.project.Project)projectDao.getById((String)value));
    }

    // -----------------------------------------------------------
    // - number
    // -----------------------------------------------------------

    private int number;

    public final int getNumber() {
        return number;
    }

    public final void setNumber(int number) {
        number = prepareNumber(number);
        if (isNumber(number)) return;
        this.number = number;
        updateLastModified();
        fireModified("number="+number);
    }

    protected int prepareNumber(int number) {
        return number;
    }

    public final boolean isNumber(int number) {
        return this.number == number;
    }

    protected final void updateNumber(Object value) {
        setNumber((Integer)value);
    }

    // -----------------------------------------------------------
    // - points
    // -----------------------------------------------------------

    private java.lang.Float points;

    public final java.lang.Float getPoints() {
        return points;
    }

    public final void setPoints(java.lang.Float points) {
        points = preparePoints(points);
        if (isPoints(points)) return;
        this.points = points;
        updateLastModified();
        fireModified("points="+points);
    }

    protected java.lang.Float preparePoints(java.lang.Float points) {
        return points;
    }

    public final boolean isPointsSet() {
        return this.points != null;
    }

    public final boolean isPoints(java.lang.Float points) {
        if (this.points == null && points == null) return true;
        return this.points != null && this.points.equals(points);
    }

    protected final void updatePoints(Object value) {
        setPoints((java.lang.Float)value);
    }

    // -----------------------------------------------------------
    // - remaining
    // -----------------------------------------------------------

    private java.lang.Float remaining;

    public final java.lang.Float getRemaining() {
        return remaining;
    }

    public final void setRemaining(java.lang.Float remaining) {
        remaining = prepareRemaining(remaining);
        if (isRemaining(remaining)) return;
        this.remaining = remaining;
        updateLastModified();
        fireModified("remaining="+remaining);
    }

    protected java.lang.Float prepareRemaining(java.lang.Float remaining) {
        return remaining;
    }

    public final boolean isRemainingSet() {
        return this.remaining != null;
    }

    public final boolean isRemaining(java.lang.Float remaining) {
        if (this.remaining == null && remaining == null) return true;
        return this.remaining != null && this.remaining.equals(remaining);
    }

    protected final void updateRemaining(Object value) {
        setRemaining((java.lang.Float)value);
    }

    // -----------------------------------------------------------
    // - state
    // -----------------------------------------------------------

    private java.lang.String state;

    public final java.lang.String getState() {
        return state;
    }

    public final void setState(java.lang.String state) {
        state = prepareState(state);
        if (isState(state)) return;
        this.state = state;
        updateLastModified();
        fireModified("state="+state);
    }

    protected java.lang.String prepareState(java.lang.String state) {
        // state = Str.removeUnreadableChars(state);
        return state;
    }

    public final boolean isStateSet() {
        return this.state != null;
    }

    public final boolean isState(java.lang.String state) {
        if (this.state == null && state == null) return true;
        return this.state != null && this.state.equals(state);
    }

    protected final void updateState(Object value) {
        setState((java.lang.String)value);
    }

    // -----------------------------------------------------------
    // - priority
    // -----------------------------------------------------------

    private int priority;

    public final int getPriority() {
        return priority;
    }

    public final void setPriority(int priority) {
        priority = preparePriority(priority);
        if (isPriority(priority)) return;
        this.priority = priority;
        updateLastModified();
        fireModified("priority="+priority);
    }

    protected int preparePriority(int priority) {
        return priority;
    }

    public final boolean isPriority(int priority) {
        return this.priority == priority;
    }

    protected final void updatePriority(Object value) {
        setPriority((Integer)value);
    }

    // -----------------------------------------------------------
    // - criticism
    // -----------------------------------------------------------

    private java.lang.String criticism;

    public final java.lang.String getCriticism() {
        return criticism;
    }

    public final void setCriticism(java.lang.String criticism) {
        criticism = prepareCriticism(criticism);
        if (isCriticism(criticism)) return;
        this.criticism = criticism;
        updateLastModified();
        fireModified("criticism="+criticism);
    }

    protected java.lang.String prepareCriticism(java.lang.String criticism) {
        // criticism = Str.removeUnreadableChars(criticism);
        return criticism;
    }

    public final boolean isCriticismSet() {
        return this.criticism != null;
    }

    public final boolean isCriticism(java.lang.String criticism) {
        if (this.criticism == null && criticism == null) return true;
        return this.criticism != null && this.criticism.equals(criticism);
    }

    protected final void updateCriticism(Object value) {
        setCriticism((java.lang.String)value);
    }

    // -----------------------------------------------------------
    // - criticismValue
    // -----------------------------------------------------------

    private int criticismValue;

    public final int getCriticismValue() {
        return criticismValue;
    }

    public final void setCriticismValue(int criticismValue) {
        criticismValue = prepareCriticismValue(criticismValue);
        if (isCriticismValue(criticismValue)) return;
        this.criticismValue = criticismValue;
        updateLastModified();
        fireModified("criticismValue="+criticismValue);
    }

    protected int prepareCriticismValue(int criticismValue) {
        return criticismValue;
    }

    public final boolean isCriticismValue(int criticismValue) {
        return this.criticismValue == criticismValue;
    }

    protected final void updateCriticismValue(Object value) {
        setCriticismValue((Integer)value);
    }

    // -----------------------------------------------------------
    // - priorityValue
    // -----------------------------------------------------------

    private int priorityValue;

    public final int getPriorityValue() {
        return priorityValue;
    }

    public final void setPriorityValue(int priorityValue) {
        priorityValue = preparePriorityValue(priorityValue);
        if (isPriorityValue(priorityValue)) return;
        this.priorityValue = priorityValue;
        updateLastModified();
        fireModified("priorityValue="+priorityValue);
    }

    protected int preparePriorityValue(int priorityValue) {
        return priorityValue;
    }

    public final boolean isPriorityValue(int priorityValue) {
        return this.priorityValue == priorityValue;
    }

    protected final void updatePriorityValue(Object value) {
        setPriorityValue((Integer)value);
    }

    // -----------------------------------------------------------
    // - label
    // -----------------------------------------------------------

    private java.lang.String label;

    public final java.lang.String getLabel() {
        return label;
    }

    public final void setLabel(java.lang.String label) {
        label = prepareLabel(label);
        if (isLabel(label)) return;
        this.label = label;
        updateLastModified();
        fireModified("label="+label);
    }

    protected java.lang.String prepareLabel(java.lang.String label) {
        // label = Str.removeUnreadableChars(label);
        return label;
    }

    public final boolean isLabelSet() {
        return this.label != null;
    }

    public final boolean isLabel(java.lang.String label) {
        if (this.label == null && label == null) return true;
        return this.label != null && this.label.equals(label);
    }

    protected final void updateLabel(Object value) {
        setLabel((java.lang.String)value);
    }

    // -----------------------------------------------------------
    // - stimulus
    // -----------------------------------------------------------

    private java.lang.String stimulus;

    public final java.lang.String getStimulus() {
        return stimulus;
    }

    public final void setStimulus(java.lang.String stimulus) {
        stimulus = prepareStimulus(stimulus);
        if (isStimulus(stimulus)) return;
        this.stimulus = stimulus;
        updateLastModified();
        fireModified("stimulus="+stimulus);
    }

    protected java.lang.String prepareStimulus(java.lang.String stimulus) {
        // stimulus = Str.removeUnreadableChars(stimulus);
        return stimulus;
    }

    public final boolean isStimulusSet() {
        return this.stimulus != null;
    }

    public final boolean isStimulus(java.lang.String stimulus) {
        if (this.stimulus == null && stimulus == null) return true;
        return this.stimulus != null && this.stimulus.equals(stimulus);
    }

    protected final void updateStimulus(Object value) {
        setStimulus((java.lang.String)value);
    }

    // -----------------------------------------------------------
    // - sourceOfStimulus
    // -----------------------------------------------------------

    private java.lang.String sourceOfStimulus;

    public final java.lang.String getSourceOfStimulus() {
        return sourceOfStimulus;
    }

    public final void setSourceOfStimulus(java.lang.String sourceOfStimulus) {
        sourceOfStimulus = prepareSourceOfStimulus(sourceOfStimulus);
        if (isSourceOfStimulus(sourceOfStimulus)) return;
        this.sourceOfStimulus = sourceOfStimulus;
        updateLastModified();
        fireModified("sourceOfStimulus="+sourceOfStimulus);
    }

    protected java.lang.String prepareSourceOfStimulus(java.lang.String sourceOfStimulus) {
        // sourceOfStimulus = Str.removeUnreadableChars(sourceOfStimulus);
        return sourceOfStimulus;
    }

    public final boolean isSourceOfStimulusSet() {
        return this.sourceOfStimulus != null;
    }

    public final boolean isSourceOfStimulus(java.lang.String sourceOfStimulus) {
        if (this.sourceOfStimulus == null && sourceOfStimulus == null) return true;
        return this.sourceOfStimulus != null && this.sourceOfStimulus.equals(sourceOfStimulus);
    }

    protected final void updateSourceOfStimulus(Object value) {
        setSourceOfStimulus((java.lang.String)value);
    }

    // -----------------------------------------------------------
    // - artifactStimulated
    // -----------------------------------------------------------

    private java.lang.String artifactStimulated;

    public final java.lang.String getArtifactStimulated() {
        return artifactStimulated;
    }

    public final void setArtifactStimulated(java.lang.String artifactStimulated) {
        artifactStimulated = prepareArtifactStimulated(artifactStimulated);
        if (isArtifactStimulated(artifactStimulated)) return;
        this.artifactStimulated = artifactStimulated;
        updateLastModified();
        fireModified("artifactStimulated="+artifactStimulated);
    }

    protected java.lang.String prepareArtifactStimulated(java.lang.String artifactStimulated) {
        // artifactStimulated = Str.removeUnreadableChars(artifactStimulated);
        return artifactStimulated;
    }

    public final boolean isArtifactStimulatedSet() {
        return this.artifactStimulated != null;
    }

    public final boolean isArtifactStimulated(java.lang.String artifactStimulated) {
        if (this.artifactStimulated == null && artifactStimulated == null) return true;
        return this.artifactStimulated != null && this.artifactStimulated.equals(artifactStimulated);
    }

    protected final void updateArtifactStimulated(Object value) {
        setArtifactStimulated((java.lang.String)value);
    }

    // -----------------------------------------------------------
    // - environment
    // -----------------------------------------------------------

    private java.lang.String environment;

    public final java.lang.String getEnvironment() {
        return environment;
    }

    public final void setEnvironment(java.lang.String environment) {
        environment = prepareEnvironment(environment);
        if (isEnvironment(environment)) return;
        this.environment = environment;
        updateLastModified();
        fireModified("environment="+environment);
    }

    protected java.lang.String prepareEnvironment(java.lang.String environment) {
        // environment = Str.removeUnreadableChars(environment);
        return environment;
    }

    public final boolean isEnvironmentSet() {
        return this.environment != null;
    }

    public final boolean isEnvironment(java.lang.String environment) {
        if (this.environment == null && environment == null) return true;
        return this.environment != null && this.environment.equals(environment);
    }

    protected final void updateEnvironment(Object value) {
        setEnvironment((java.lang.String)value);
    }

    // -----------------------------------------------------------
    // - response
    // -----------------------------------------------------------

    private java.lang.String response;

    public final java.lang.String getResponse() {
        return response;
    }

    public final void setResponse(java.lang.String response) {
        response = prepareResponse(response);
        if (isResponse(response)) return;
        this.response = response;
        updateLastModified();
        fireModified("response="+response);
    }

    protected java.lang.String prepareResponse(java.lang.String response) {
        // response = Str.removeUnreadableChars(response);
        return response;
    }

    public final boolean isResponseSet() {
        return this.response != null;
    }

    public final boolean isResponse(java.lang.String response) {
        if (this.response == null && response == null) return true;
        return this.response != null && this.response.equals(response);
    }

    protected final void updateResponse(Object value) {
        setResponse((java.lang.String)value);
    }

    // -----------------------------------------------------------
    // - responseMeasure
    // -----------------------------------------------------------

    private java.lang.String responseMeasure;

    public final java.lang.String getResponseMeasure() {
        return responseMeasure;
    }

    public final void setResponseMeasure(java.lang.String responseMeasure) {
        responseMeasure = prepareResponseMeasure(responseMeasure);
        if (isResponseMeasure(responseMeasure)) return;
        this.responseMeasure = responseMeasure;
        updateLastModified();
        fireModified("responseMeasure="+responseMeasure);
    }

    protected java.lang.String prepareResponseMeasure(java.lang.String responseMeasure) {
        // responseMeasure = Str.removeUnreadableChars(responseMeasure);
        return responseMeasure;
    }

    public final boolean isResponseMeasureSet() {
        return this.responseMeasure != null;
    }

    public final boolean isResponseMeasure(java.lang.String responseMeasure) {
        if (this.responseMeasure == null && responseMeasure == null) return true;
        return this.responseMeasure != null && this.responseMeasure.equals(responseMeasure);
    }

    protected final void updateResponseMeasure(Object value) {
        setResponseMeasure((java.lang.String)value);
    }

    // -----------------------------------------------------------
    // - qualitys
    // -----------------------------------------------------------

    private java.util.Set<String> qualitysIds = new java.util.HashSet<String>();

    public final java.util.Set<scrum.server.project.Quality> getQualitys() {
        return (java.util.Set) qualityDao.getByIdsAsSet(this.qualitysIds);
    }

    public final void setQualitys(Collection<scrum.server.project.Quality> qualitys) {
        qualitys = prepareQualitys(qualitys);
        if (qualitys == null) qualitys = Collections.emptyList();
        java.util.Set<String> ids = getIdsAsSet(qualitys);
        if (this.qualitysIds.equals(ids)) return;
        this.qualitysIds = ids;
        updateLastModified();
        fireModified("qualitys="+Str.format(qualitys));
    }

    protected Collection<scrum.server.project.Quality> prepareQualitys(Collection<scrum.server.project.Quality> qualitys) {
        return qualitys;
    }

    protected void repairDeadQualityReference(String entityId) {
        if (this.qualitysIds.remove(entityId)) fireModified("qualitys-=" + entityId);
    }

    public final boolean containsQuality(scrum.server.project.Quality quality) {
        if (quality == null) return false;
        return this.qualitysIds.contains(quality.getId());
    }

    public final int getQualitysCount() {
        return this.qualitysIds.size();
    }

    public final boolean isQualitysEmpty() {
        return this.qualitysIds.isEmpty();
    }

    public final boolean addQuality(scrum.server.project.Quality quality) {
        if (quality == null) throw new IllegalArgumentException("quality == null");
        boolean added = this.qualitysIds.add(quality.getId());
        if (added) updateLastModified();
        if (added) fireModified("qualitys+=" + quality);
        return added;
    }

    public final boolean addQualitys(Collection<scrum.server.project.Quality> qualitys) {
        if (qualitys == null) throw new IllegalArgumentException("qualitys == null");
        boolean added = false;
        for (scrum.server.project.Quality quality : qualitys) {
            added = added | this.qualitysIds.add(quality.getId());
        }
        return added;
    }

    public final boolean removeQuality(scrum.server.project.Quality quality) {
        if (quality == null) throw new IllegalArgumentException("quality == null");
        if (this.qualitysIds == null) return false;
        boolean removed = this.qualitysIds.remove(quality.getId());
        if (removed) updateLastModified();
        if (removed) fireModified("qualitys-=" + quality);
        return removed;
    }

    public final boolean removeQualitys(Collection<scrum.server.project.Quality> qualitys) {
        if (qualitys == null) return false;
        if (qualitys.isEmpty()) return false;
        boolean removed = false;
        for (scrum.server.project.Quality _element: qualitys) {
            removed = removed | removeQuality(_element);
        }
        return removed;
    }

    public final boolean clearQualitys() {
        if (this.qualitysIds.isEmpty()) return false;
        this.qualitysIds.clear();
        updateLastModified();
        fireModified("qualitys cleared");
        return true;
    }

    protected final void updateQualitys(Object value) {
        Collection<String> ids = (Collection<String>) value;
        setQualitys((java.util.Set) qualityDao.getByIdsAsSet(ids));
    }

    // -----------------------------------------------------------
    // - storiesAssociates
    // -----------------------------------------------------------

    private java.util.Set<String> storiesAssociatesIds = new java.util.HashSet<String>();

    public final java.util.Set<scrum.server.project.Requirement> getStoriesAssociates() {
        return (java.util.Set) requirementDao.getByIdsAsSet(this.storiesAssociatesIds);
    }

    public final void setStoriesAssociates(Collection<scrum.server.project.Requirement> storiesAssociates) {
        storiesAssociates = prepareStoriesAssociates(storiesAssociates);
        if (storiesAssociates == null) storiesAssociates = Collections.emptyList();
        java.util.Set<String> ids = getIdsAsSet(storiesAssociates);
        if (this.storiesAssociatesIds.equals(ids)) return;
        this.storiesAssociatesIds = ids;
        updateLastModified();
        fireModified("storiesAssociates="+Str.format(storiesAssociates));
    }

    protected Collection<scrum.server.project.Requirement> prepareStoriesAssociates(Collection<scrum.server.project.Requirement> storiesAssociates) {
        return storiesAssociates;
    }

    protected void repairDeadStoriesAssociateReference(String entityId) {
        if (this.storiesAssociatesIds.remove(entityId)) fireModified("storiesAssociates-=" + entityId);
    }

    public final boolean containsStoriesAssociate(scrum.server.project.Requirement storiesAssociate) {
        if (storiesAssociate == null) return false;
        return this.storiesAssociatesIds.contains(storiesAssociate.getId());
    }

    public final int getStoriesAssociatesCount() {
        return this.storiesAssociatesIds.size();
    }

    public final boolean isStoriesAssociatesEmpty() {
        return this.storiesAssociatesIds.isEmpty();
    }

    public final boolean addStoriesAssociate(scrum.server.project.Requirement storiesAssociate) {
        if (storiesAssociate == null) throw new IllegalArgumentException("storiesAssociate == null");
        boolean added = this.storiesAssociatesIds.add(storiesAssociate.getId());
        if (added) updateLastModified();
        if (added) fireModified("storiesAssociates+=" + storiesAssociate);
        return added;
    }

    public final boolean addStoriesAssociates(Collection<scrum.server.project.Requirement> storiesAssociates) {
        if (storiesAssociates == null) throw new IllegalArgumentException("storiesAssociates == null");
        boolean added = false;
        for (scrum.server.project.Requirement storiesAssociate : storiesAssociates) {
            added = added | this.storiesAssociatesIds.add(storiesAssociate.getId());
        }
        return added;
    }

    public final boolean removeStoriesAssociate(scrum.server.project.Requirement storiesAssociate) {
        if (storiesAssociate == null) throw new IllegalArgumentException("storiesAssociate == null");
        if (this.storiesAssociatesIds == null) return false;
        boolean removed = this.storiesAssociatesIds.remove(storiesAssociate.getId());
        if (removed) updateLastModified();
        if (removed) fireModified("storiesAssociates-=" + storiesAssociate);
        return removed;
    }

    public final boolean removeStoriesAssociates(Collection<scrum.server.project.Requirement> storiesAssociates) {
        if (storiesAssociates == null) return false;
        if (storiesAssociates.isEmpty()) return false;
        boolean removed = false;
        for (scrum.server.project.Requirement _element: storiesAssociates) {
            removed = removed | removeStoriesAssociate(_element);
        }
        return removed;
    }

    public final boolean clearStoriesAssociates() {
        if (this.storiesAssociatesIds.isEmpty()) return false;
        this.storiesAssociatesIds.clear();
        updateLastModified();
        fireModified("storiesAssociates cleared");
        return true;
    }

    protected final void updateStoriesAssociates(Object value) {
        Collection<String> ids = (Collection<String>) value;
        setStoriesAssociates((java.util.Set) requirementDao.getByIdsAsSet(ids));
    }

    public void updateProperties(Map<?, ?> properties) {
        for (Map.Entry entry : properties.entrySet()) {
            String property = (String) entry.getKey();
            if (property.equals("id")) continue;
            Object value = entry.getValue();
            if (property.equals("projectId")) updateProject(value);
            if (property.equals("number")) updateNumber(value);
            if (property.equals("points")) updatePoints(value);
            if (property.equals("remaining")) updateRemaining(value);
            if (property.equals("state")) updateState(value);
            if (property.equals("priority")) updatePriority(value);
            if (property.equals("criticism")) updateCriticism(value);
            if (property.equals("criticismValue")) updateCriticismValue(value);
            if (property.equals("priorityValue")) updatePriorityValue(value);
            if (property.equals("label")) updateLabel(value);
            if (property.equals("stimulus")) updateStimulus(value);
            if (property.equals("sourceOfStimulus")) updateSourceOfStimulus(value);
            if (property.equals("artifactStimulated")) updateArtifactStimulated(value);
            if (property.equals("environment")) updateEnvironment(value);
            if (property.equals("response")) updateResponse(value);
            if (property.equals("responseMeasure")) updateResponseMeasure(value);
            if (property.equals("qualitysIds")) updateQualitys(value);
            if (property.equals("storiesAssociatesIds")) updateStoriesAssociates(value);
        }
    }

    protected void repairDeadReferences(String entityId) {
        super.repairDeadReferences(entityId);
        repairDeadProjectReference(entityId);
        if (this.qualitysIds == null) this.qualitysIds = new java.util.HashSet<String>();
        repairDeadQualityReference(entityId);
        if (this.storiesAssociatesIds == null) this.storiesAssociatesIds = new java.util.HashSet<String>();
        repairDeadStoriesAssociateReference(entityId);
    }

    // --- ensure integrity ---

    public void ensureIntegrity() {
        super.ensureIntegrity();
        if (!isProjectSet()) {
            repairMissingMaster();
            return;
        }
        try {
            getProject();
        } catch (EntityDoesNotExistException ex) {
            LOG.info("Repairing dead project reference");
            repairDeadProjectReference(this.projectId);
        }
        if (this.qualitysIds == null) this.qualitysIds = new java.util.HashSet<String>();
        Set<String> qualitys = new HashSet<String>(this.qualitysIds);
        for (String entityId : qualitys) {
            try {
                qualityDao.getById(entityId);
            } catch (EntityDoesNotExistException ex) {
                LOG.info("Repairing dead quality reference");
                repairDeadQualityReference(entityId);
            }
        }
        if (this.storiesAssociatesIds == null) this.storiesAssociatesIds = new java.util.HashSet<String>();
        Set<String> storiesAssociates = new HashSet<String>(this.storiesAssociatesIds);
        for (String entityId : storiesAssociates) {
            try {
                requirementDao.getById(entityId);
            } catch (EntityDoesNotExistException ex) {
                LOG.info("Repairing dead storiesAssociate reference");
                repairDeadStoriesAssociateReference(entityId);
            }
        }
    }


    // -----------------------------------------------------------
    // - dependencies
    // -----------------------------------------------------------

    static scrum.server.project.ProjectDao projectDao;

    public static final void setProjectDao(scrum.server.project.ProjectDao projectDao) {
        GScenario.projectDao = projectDao;
    }

    static scrum.server.project.QualityDao qualityDao;

    public static final void setQualityDao(scrum.server.project.QualityDao qualityDao) {
        GScenario.qualityDao = qualityDao;
    }

    static scrum.server.project.RequirementDao requirementDao;

    public static final void setRequirementDao(scrum.server.project.RequirementDao requirementDao) {
        GScenario.requirementDao = requirementDao;
    }

    static scrum.server.project.ScenarioDao scenarioDao;

    public static final void setScenarioDao(scrum.server.project.ScenarioDao scenarioDao) {
        GScenario.scenarioDao = scenarioDao;
    }

}